<template>
	<view class="pages">
		<view class="pages_title">
			{{$t('resetPassword.ResetPassword')}}
		</view>

		<view class="items">
			<view class="itemsTip">
				{{$t('Password1')}}
			</view>
			<view class="sd">
				<u--input :placeholder="$t('resetPasswordsubmit.Password.placeholder')" border="surround" v-model="FormData.password_hash"
					:customStyle="{width:'650rpx',height:'49rpx'}" password></u--input>
			</view>
		</view>
		<view class="items">
			<view class="itemsTip">
				{{$t('resetPasswordsubmit.ConfirmPassword')}}
			</view>
			<view class="sd">
				<u--input :placeholder="$t('resetPasswordsubmit.ConfirmPassword.placeholder')" border="surround" v-model="FormData.renew_password_hash"
					:customStyle="{width:'650rpx',height:'49rpx'}" password></u--input>
			</view>
		</view>
		<view class="items">
			<view class="itemsTip">
				{{$t('resetPasswordsubmit.code')}}
			</view>
			<view class="sd">
				<u--input :placeholder="$t('resetPasswordsubmit.placeholder')" border="surround" v-model="FormData.code"
					:customStyle="{width:'650rpx',height:'49rpx'}"></u--input>
			</view>
		</view>
		<u-button type="primary" :text="$t('resetPasswordsubmit.SetNewPassword')"
			:customStyle="{width:'100%',height:'80rpx',backgroundColor:'#273562',color:'#fff',margin:'30rpx auto 0rpx',fontWeight:'700',border:'none'}" @click="goSendEmail"></u-button>
<u-button type="primary" :text="$t('resetPassword.Backtologin')"
			:customStyle="{width:'100%',height:'80rpx',backgroundColor:'#273562',color:'#fff',margin:'30rpx auto 0rpx',fontWeight:'700',border:'none'}"
			@click="$next('/pages/index/login/login')"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				newUrl:1,//0为新接口1为老接口
				FormData:{
					email:'',
					code:'',
					password_hash: '',
					renew_password_hash: '',
				}
			}
		},
		onLoad(options) {
			this.FormData.email = options.email
		},
		methods: {
			// 发邮箱
			goSendEmail() {
				if(!this.FormData.password_hash) {
					this.$ToastFail(this.$t('login.Passwordtips'))
					return
				}
				if(!this.FormData.renew_password_hash) {
					this.$ToastFail(this.$t('resetPasswordsubmit.ConfirmPassword.placeholder'))
					return
				}
				if(!this.FormData.code) {
					this.$ToastFail(this.$t('resetPasswordsubmit.placeholder'))
					return
				}
				
				if(this.FormData.password_hash !== this.FormData.renew_password_hash) {
					this.$ToastFail(this.$t('oldorvalue'))
					return
				}
				uni.showLoading({
					title: this.$t('Laoding'),
				})
				this.$post(`/backend/login/editPassword`,this.FormData,this.newUrl).then(res => {
					if (res.status) {
						console.log(res,1111111111111111
						);
						this.$ToastOk(`${res.data.msg}`)
						setTimeout(() => {
							uni.navigateTo({
								url: '/pages/index/login/login'
							})
						}, 1000)
					} else {
						this.$ToastFail(`${res.message}`)
					}
				})
			}
		}
	}
</script>

<style>
	.pages {
		padding: 0 40rpx 80rpx;
		width: 100%;
		height: 100vh;
		overflow-y: auto;
		box-sizing: border-box;
	}

	.pages_title {
		font-family: Roboto;
		font-size: 24px;
		font-weight: 500;
		line-height: 24px;
		letter-spacing: 0em;
		text-align: left;
		/* margin-top: 40rpx; */
		margin: 40rpx 0 168rpx;
	}

	.pages_tips {
		font-family: Roboto;
		font-size: 18px;
		font-weight: 500;
		line-height: 22px;
		letter-spacing: 0em;
		text-align: left;
		margin-top: 168rpx;
	}

	.items {
		display: flex;
		align-items: flex-start;
		justify-content: center;
		flex-direction: column;
		width: 100%;
		height: 160rpx;
		margin: 2rpx auto 0;
		/* padding: 0 36rpx; */
		box-sizing: border-box;
	}

	.itemsTip {
		height: 54rpx;
		font-family: Roboto;
		font-size: 16px;
		font-weight: 500;
		line-height: 40rpx;
		letter-spacing: 0em;
		text-align: left;

	}

	.sd {
		display: flex;
		/* justify-content: flex-start; */
		align-items: center;
		width: 100%;
		height: 80rpx;
		/* background-color: red; */
	}
</style>